#!/bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src

# Test Go support: Simple things.

cat <<\EOF > xg-go-6.go
package main

import (
	"fmt"
	"github.com/leonelquinteros/gotext"
)

func main () {
	// Specify localedir, domain.
	gotext.Configure(".", "fr_FR", "hello")

	// C++ style comment
	fmt.Println(gotext.Get("Test 1"))
	/* C style comment */
	fmt.Println(gotext.Get("Test 2"))
	// Raw string literals
	fmt.Println(gotext.Get(`Test 3`))
	fmt.Println(gotext.Get(`first line
second line
third line`))
	// String literal concatenation
	fmt.Println(gotext.Get(`Test 4` + "711"))
	fmt.Println(
		// a
		gotext.Get("Test 5" + " part2"))
	fmt.Println(gotext.Get(
		// a
		"Test 6" + " part2"))
	fmt.Println( // a
		gotext // b
		. // c
		Get // d
		( // e
		"Test 7" // f
		+ // g
		" part2"
		));
	// Empty string
	fmt.Println(gotext.Get(""))
}
EOF

: ${XGETTEXT=xgettext}
${XGETTEXT} -c -d xg-go-6.tmp xg-go-6.go || Exit 1
LC_ALL=C tr -d '\r' < xg-go-6.tmp.po > xg-go-6.po || Exit 1

sed -e '/POT-Creation-Date/d' < xg-go-6.po > xg-go-6.pot

cat <<\EOF > xg-go-6.ok
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#. Empty string
#: xg-go-6.go:39
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

#. C++ style comment
#: xg-go-6.go:13
msgid "Test 1"
msgstr ""

#. C style comment
#: xg-go-6.go:15
msgid "Test 2"
msgstr ""

#. Raw string literals
#: xg-go-6.go:17
msgid "Test 3"
msgstr ""

#: xg-go-6.go:18
msgid ""
"first line\n"
"second line\n"
"third line"
msgstr ""

#. String literal concatenation
#: xg-go-6.go:22
msgid "Test 4711"
msgstr ""

#. a
#: xg-go-6.go:25
msgid "Test 5 part2"
msgstr ""

#. a
#: xg-go-6.go:28
msgid "Test 6 part2"
msgstr ""

#. d
#. e
#: xg-go-6.go:34
msgid "Test 7 part2"
msgstr ""
EOF

: ${DIFF=diff}
${DIFF} xg-go-6.ok xg-go-6.pot || Exit 1

exit 0
